package org.dfg.corejava.designPattern.thread.sync;

import java.nio.ByteBuffer;

public class SyncTest1 extends Thread {
	private ByteBuffer bb;

	public SyncTest1(ByteBuffer bb) {
		this.bb = bb;
	}

	public static void main(String[] args) {
		ByteBuffer bb = ByteBuffer.allocate(99);
		final SyncTestReader r = new SyncTestReader(bb);
		SyncTestWriter w = new SyncTestWriter(bb);
		w.start();
		r.start();
		new Thread(new Runnable() {

			@Override
			public void run() {
				long s = System.currentTimeMillis();
				while (System.currentTimeMillis() - s < 5000) {
					r.interrupt();// 实际上无法中断，始终在等待
				}
			}
		}).start();
	}
}
